using System;
using System.Data;
using System.Configuration;
using System.Collections;
using Reimers.Map;
using Reimers.Map.CustomMaps;

public partial class examples_csharp_wmsmap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //Center the map
            CMap.Zoom = 4;
            CMap.Latitude = 39;
            CMap.Longitude = -77;
            //Add controls
            CMap.MapControls.Add(new Reimers.Map.Controls.GoogleLargeMapControl("lmc"));
            CMap.MapControls.Add(new Reimers.Map.Controls.GoogleNormalMapTypeControl("nmtc"));
            
            //Create the tile layer for teh WMS tiles.
            WMSTileLayer xtl = new WMSTileLayer("xtl");
            xtl.BaseUrls.Add("http://wms.jpl.nasa.gov/wms.cgi?");
            xtl.Styles = "Jan";
            xtl.IsPng = false;
            xtl.Layers = "BMNG";
            xtl.Copyrights = new GoogleCopyrightCollection();
            xtl.Copyrights.ID = "cpxtl";
            GoogleCopyright cp = new GoogleCopyright();
            cp.ID = 10;
            cp.Bounds = new GoogleBounds(-86, -180, 86, 180);
            cp.CopyrightText = "<a href=\"http://OnEarth.jpl.nasa.gov/index.html\">JPL World Map Service</a>";
            xtl.Copyrights.Copyrights.Add(cp);
            
            //Create the custom map type.
            CustomMapType cmt = new CustomMapType();
            cmt.ID = "cmt";
            cmt.Name = "NASA";
            cmt.Projection = new MercatorProjection("mp", 21);
            //Add the tile layer to the custom map.
            cmt.Layers.Add(xtl);

            //Clear the map types and add only the custom map.
            CMap.Options.MapTypes.Clear();
            CMap.Options.MapTypes.Add(cmt);
        }
        if (Page.IsPostBack)
        {
            CustomMapType cm = (CustomMapType)CMap.Options.MapTypes[0];
            ((WMSTileLayer)cm.Layers[0]).Styles = ddlMonth.SelectedValue;
        }
    }
}
